<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>code.js.cn</title>
<style type="text/css">
#info input{display:block;}
</style>
</head>
<body>
<button id="addEl">add Element</button>
<div id="info"></div>
<span>ref:http://bbs.51js.com/viewthread.php?tid=87369&extra=page%3D1</span>
</body>
<script type="text/javascript">
//<![CDATA[
function live(type, fn, where) {
	var d = document,
	atta = !!d.attachEvent,
	bf = /blur|focus/i.test(type);
	if (bf) {
		d = d.body;
		if (atta) type += 'in';
	};
	d[atta ? 'attachEvent': 'addEventListener']((atta ? 'on': '') + type, function(e) {
		e = e || window.event;
		var el = e.target || e.srcElement;
		if (el != d && where.call(el)) fn.call(el, e)
	}, bf)
};
/*
use
*/

var $= function (q,p){
    return p?arguments.callee(p).getElementsByTagName(q)
        :(typeof q == 'string' ? document.getElementById(q):q) 
};

live('focus',function (){
   this.style.color='red'
},function (){
    return this.tagName.toLowerCase()=='input'
});

$('addEl').onclick=function (){
   var x= $('info').appendChild(document.createElement('INPUT'))
   x.value='51js.com'
}
 //]]>
</script>
</html>